<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/xadmin/css/font.css">
    <link rel="stylesheet" href="/static/xadmin/css/xadmin.css">
    <link rel="stylesheet" href="/static/css/apublic.css">
    <script src="/static/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/xadmin/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="/static/xadmin/html5.min.js"></script>
    <script src="/static/xadmin/respond.min.js"></script>
    <![endif]-->
    <script src="/static/until.js" charset="utf-8"></script>
    <script>
        if(!sessionStorage.getItem('token')) window.top.location.href='/login.html';
    </script>
    <style>
        .layui-icon-close{
            cursor:pointer;
        }
        .layui-icon-close:hover{
            color:red;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="myform" lay-filter="myform">
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label"><span class="x-red">*</span>账号</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_username" name="username" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_status" class="layui-form-label"><span class="x-red">*</span>状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="status" value="1" title="启用">
                    <input type="radio" name="status" value="2" title="禁用" >
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_create_at" class="layui-form-label"><span class="x-red">*</span>创建时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_create_at" name="create_at" required="" lay-verify="required" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_update_at" class="layui-form-label"><span class="x-red">*</span>更新时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_update_at" name="update_at" required="" lay-verify="required" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <input type="hidden" name="id" value=""/>
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="filter_btn" lay-submit="">修改</button></div>
        </form>
    </div>
</div>
<script>
    var detail_url="/authuser/detail"
    var edit_url="/authuser/edit"
    layui.use(['form', 'layer','jquery','laydate'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(filter_btn)', function(data) {
                //发异步，把数据提交给php
                u_post(edit_url,data.field,function(res){
                    if(res.status.errorCode==0) {
                        layer.msg("成功",{time:1000})
                        window.parent.table.reload('mytable',{});
                    }
                    else{
                        layer.alert(res.status.msg, {icon: 5})
                    }
                });

                return false;
            });
            //date
            layui.laydate.render({elem: '#L_create_at',type: 'datetime',trigger: 'click'});
            layui.laydate.render({elem: '#L_update_at',type: 'datetime',trigger: 'click'});
            u_post(detail_url,{id:getQueryString("id")},function(res){
                if(res.status.errorCode==0) {
                    var newData={}
                    for (var key in res.data)
                    {
                        if(key=="create_at"||key=="delete_at"||key=="update_at")
                            newData[key]=utc2datetime(res.data[key])
                        else
                            newData[key]=res.data[key]
                    }
                    form.val("myform", newData);
                }
                else{
                    layer.alert(res.status.msg, {icon: 5})
                }
            });
        });
</script>

</body>

</html>
